package com.ym.wcp.framework.utils;

import java.util.regex.Pattern;

public class RegxUtil {

    public static boolean isNumeric(String str) {
        return Pattern.matches("[0-9]*", str);
    }

    public static String filterSymbol(String s) {
        String regEx = "[`~!@#$%^&*()+=|{}:;\\\\[\\\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？']";
        return Pattern.compile(regEx).matcher(s).replaceAll("").trim();
    }

    public static boolean isChinese(String chinese) {
        return Pattern.matches("^[\u4e00-\u9fa5]$", chinese);
    }

    public static boolean isMobile(String phone) {
        return Pattern.matches("^[1][1,2,3,4,5,7,8,9][0-9]{9}$", phone);
    }

    public static boolean isHttpUrl(String url) {
        return Pattern.matches("http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?", url);
    }

    public static boolean isNotEmpty(String content) {
        return Pattern.matches("^\\S+$", content == null ? "" : content);
    }

    public static boolean isLetter(String content) {
        return Pattern.matches("^[A-Za-z]+$", content);
    }

    public static boolean isLetterUpper(String content) {
        return Pattern.matches("^[A-Z]+$", content);
    }

    public static boolean isLetterLower(String content) {
        return Pattern.matches("^[a-z]+$", content);
    }

    public static boolean isIdCard(String content) {
        return Pattern.matches("^(\\d{15}$|^\\d{18}$|^\\d{17}(\\d|X|x))$", content);
    }
}
